#include "qrenderarea.h"
#include "ui_qrenderarea.h"
#include <QPainter>
#include "qpaintutils.h"

QRenderArea::QRenderArea(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::QRenderArea)
{
    ui->setupUi(this);

    shouldIDraw = false;
}

QRenderArea::~QRenderArea()
{
    delete ui;
}

void QRenderArea::setColor(QColor *color)
{
    this->color = color;
    update();
}

void QRenderArea::setText(QString text)
{
    this->text = text;
    update();
}

void QRenderArea::setDiameter(int d)
{
    this->d = d;
    update();
}

void QRenderArea::draw(bool shouldIDraw)
{
    this->shouldIDraw = shouldIDraw;
    update();
}

QSize QRenderArea::sizeHint() const
{
    return QSize(400, 200);
}

QSize QRenderArea::minimumSizeHint() const
{
    return QSize(100, 100);
}

void QRenderArea::paintEvent(QPaintEvent *)
{
    if(shouldIDraw)
    {
        QPainter painter(this);
        QPoint center(width() / 2, height() / 2);

        QPaintUtils::drawCircle(&painter, &center, d, text, 20, color);
    }
}

QColor* QRenderArea::getColor()
{
    return color;
}
int QRenderArea::getDiameter()
{
    return d;
}
QString QRenderArea::getText()
{
    return text;
}
